home *** CD-ROM | disk | FTP | other *** search
/ Your Choice 3 / Your Choice Software Collection 3.iso / prgmming / aotsr / ao.asm next >
Assembly Source File  |  1994-07-09  |  6KB  |  340 lines

  1.  
  2.         title        -  Animated "o" system program
  3.  
  4. vectors     segment at 0
  5.         ORG    8h*4
  6. timer    label    dword
  7.         ORG    16h*4
  8. kbio    label    dword
  9. vectors     ends
  10.  
  11. cseg        segment para
  12.         assume    cs:cseg
  13.         org    100h
  14.  
  15. begin:        jmp    init_vectors        ; go initialize vectors
  16.  
  17.  
  18. ;-------------------------------;
  19. ;                ;
  20. ;  data area for this program    ;
  21. ;                ;
  22. ;-------------------------------;
  23.  
  24. old_timer    dd    ?    ; Old timer interrupt location
  25. old_kbio    dd    ?    ; Old keyboard I/O interrupt location
  26. timer_tick    db    0    ; set if timer ticked
  27. in_kbio        db    0
  28. which        db    0    ; selector in "o_table"
  29. csize        db    10h    ; size of character in bytes in "o_table"
  30. enabled        db    1    ; spinning "o"s enabled flag
  31. shift_ticks    db    0
  32. o_table:            ; font table of spinning "o"s
  33.     db    00000000b
  34.     db    00000000b
  35.     db    00000000b
  36.     db    00000000b
  37.     db    00000000b
  38.     db    00110000b
  39.     db    01100000b
  40.     db    11100000b
  41.     db    11010110b
  42.     db    11001110b
  43.     db    01101100b
  44.     db    00111000b
  45.     db    00000000b
  46.     db    00000000b
  47.     db    00000000b
  48.     db    00000000b
  49.  
  50.     db    00000000b
  51.     db    00000000b
  52.     db    00000000b
  53.     db    00000000b
  54.     db    00000000b
  55.     db    00111000b
  56.     db    01101100b
  57.     db    11010000b
  58.     db    11010000b
  59.     db    11010000b
  60.     db    01101100b
  61.     db    00111000b
  62.     db    00000000b
  63.     db    00000000b
  64.     db    00000000b
  65.     db    00000000b
  66.  
  67.     db    00000000b
  68.     db    00000000b
  69.     db    00000000b
  70.     db    00000000b
  71.     db    00000000b
  72.     db    00111000b
  73.     db    01101100b
  74.     db    11001110b
  75.     db    11010110b
  76.     db    11100000b
  77.     db    01100000b
  78.     db    00110000b
  79.     db    00000000b
  80.     db    00000000b
  81.     db    00000000b
  82.     db    00000000b
  83.  
  84.     db    00000000b
  85.     db    00000000b
  86.     db    00000000b
  87.     db    00000000b
  88.     db    00000000b
  89.     db    00111000b
  90.     db    01101100b
  91.     db    11000110b
  92.     db    11111110b
  93.     db    11000110b
  94.     db    01000100b
  95.     db    00000000b
  96.     db    00000000b
  97.     db    00000000b
  98.     db    00000000b
  99.     db    00000000b
  100.  
  101.     db    00000000b
  102.     db    00000000b
  103.     db    00000000b
  104.     db    00000000b
  105.     db    00000000b
  106.     db    00111000b
  107.     db    01101100b
  108.     db    11100110b
  109.     db    11010110b
  110.     db    00001110b
  111.     db    00001100b
  112.     db    00011000b
  113.     db    00000000b
  114.     db    00000000b
  115.     db    00000000b
  116.     db    00000000b
  117.  
  118.     db    00000000b
  119.     db    00000000b
  120.     db    00000000b
  121.     db    00000000b
  122.     db    00000000b
  123.     db    00111000b
  124.     db    01101100b
  125.     db    00010110b
  126.     db    00010110b
  127.     db    00010110b
  128.     db    01101100b
  129.     db    00111000b
  130.     db    00000000b
  131.     db    00000000b
  132.     db    00000000b
  133.     db    00000000b
  134.  
  135.     db    00000000b
  136.     db    00000000b
  137.     db    00000000b
  138.     db    00000000b
  139.     db    00000000b
  140.     db    00011000b
  141.     db    00001100b
  142.     db    00001110b
  143.     db    11010110b
  144.     db    11100110b
  145.     db    01101100b
  146.     db    00111000b
  147.     db    00000000b
  148.     db    00000000b
  149.     db    00000000b
  150.     db    00000000b
  151.  
  152.     db    00000000b
  153.     db    00000000b
  154.     db    00000000b
  155.     db    00000000b
  156.     db    00000000b
  157.     db    00000000b
  158.     db    01000100b
  159.     db    11000110b
  160.     db    11111110b
  161.     db    11000110b
  162.     db    01101100b
  163.     db    00111000b
  164.     db    00000000b
  165.     db    00000000b
  166.     db    00000000b
  167.     db    00000000b
  168.  
  169.     db    00000000b
  170.     db    00000000b
  171.     db    00000000b
  172.     db    00000000b
  173.     db    00000000b
  174.     db    00111000b
  175.     db    01101100b
  176.     db    11000110b
  177.     db    11000110b
  178.     db    11000110b
  179.     db    01101100b
  180.     db    00111000b
  181.     db    00000000b
  182.     db    00000000b
  183.     db    00000000b
  184.     db    00000000b
  185.  
  186. ; The keyboard I/O interrupt intercept routine follows.
  187. intercept    proc    far
  188.         cli
  189.         nop
  190.         pushf
  191.         cmp    timer_tick,0    ; wait 1/18 of a second before font update
  192.         je    dont_do_this
  193.         cmp    in_kbio,1    ; make sure we don't overflow any stacks
  194.         ja    dont_do_this
  195.         cmp    ah,1        ; only update font on keyboard poll
  196.         je    do_this
  197.         cmp    ah,11h        ; extended keyboard poll
  198.         je    do_this
  199. dont_do_this:
  200.         jmp    go_kbio1
  201. do_this:
  202.         mov    timer_tick,0
  203.         inc    in_kbio
  204.         push    es
  205.         push    ds
  206.         push    si
  207.         push    di
  208.         push    bp
  209.         push    ax
  210.         push    bx
  211.         push    cx
  212.         push    dx
  213.  
  214.         mov    ax,040h
  215.         mov    es,ax        ; load BIOS data segment
  216.  
  217.         mov    bh,es:[85h]    ; Character height
  218.         cmp    bh,14
  219.         jb    close_jmp
  220.         cmp    bh,16
  221.         ja    close_jmp
  222.         mov    al,es:[49h]    ; Video mode
  223.         cmp    al,3
  224.         je    mode_ok
  225. close_jmp:
  226.         jmp    go_kbio
  227. mode_ok:
  228.         cmp    in_kbio,1
  229.         jne    still_counting
  230.  
  231.         mov    al,es:[17h]    ; Get keyboard flags
  232.         and    al,3
  233.         cmp    al,3
  234.         jne    shifts_not_down
  235.         inc    shift_ticks    ; both shift keys are down
  236.         cmp    shift_ticks,18
  237.         jne    still_counting
  238.         xor    enabled,1    ; toggle enabled status
  239.         jmp    enabled_status_changed
  240. shifts_not_down:
  241.         mov    shift_ticks,0
  242. still_counting:
  243.         cmp    enabled,0
  244.         je    go_kbio
  245. enabled_status_changed:
  246.         mov    dx,es:[63h]    ; video controller base address
  247.         add    dl,6        ; address of status register
  248. updating:
  249.         nop
  250.         nop
  251.         cli
  252.         nop
  253.         in    al,dx        ; get vertical retrace status
  254.         test    al,8
  255.         jnz    now        ; jump if in vertical retrace
  256.         sti            ; temporarily enable interrupts
  257.         jmp    updating
  258. now:
  259.         cmp    enabled,0
  260.         je    load_orig    ; jump to load a plain, unbroken "o"
  261.         mov    al,which    ; get which "o" to load
  262.         inc    al
  263.         and    al,7        ; 8 possible "o"s to load
  264.         mov    which,al
  265.         jmp    load_next_o
  266. load_orig:
  267.         mov    al,8
  268. load_next_o:
  269.         mul    csize        ; make index into "o_table"
  270.         mov    bp,offset o_table
  271.         add    bp,ax
  272.         mov    ax,cs
  273.         mov    es,ax
  274.         mov    ax,01100h    ; do interrupt to load character font
  275.         mov    bl,0        ; table number
  276.                     ; bh = number of bytes per character
  277.         mov    cx,1        ; number of characters to load
  278.         mov    dx,06fh        ; ASCII value of "o"
  279.         int    10h
  280. go_kbio:
  281.         pop    dx
  282.         pop    cx
  283.         pop    bx
  284.         pop    ax
  285.         pop    bp
  286.         pop    di
  287.         pop    si
  288.         pop    ds
  289.         pop    es
  290.         dec    in_kbio
  291. go_kbio1:
  292.         popf
  293.         jmp    old_kbio
  294. intercept     endp
  295.  
  296. ; The new timer interrupt routine follows.
  297. new_timer    proc    far
  298.         mov    timer_tick,1
  299.         jmp    old_timer
  300. new_timer    endp
  301.  
  302. ; Do TSR initialization.
  303. init_vectors    proc    near
  304.         assume    ds:vectors
  305.         mov    ax,vectors
  306.         mov    ds,ax
  307.  
  308.         cli
  309. ; Load timer interrupt vector.
  310.         mov    ax,word ptr timer
  311.         mov    word ptr old_timer,ax
  312.         mov    ax,word ptr timer[2]
  313.         mov    word ptr old_timer[2],ax
  314.         mov    ax, offset new_timer
  315.         mov    word ptr timer,ax
  316.         mov    word ptr timer[2],cs
  317.  
  318. ; Load keyboard I/O interrupt vector.
  319.         mov    ax,word ptr kbio
  320.         mov    word ptr old_kbio,ax
  321.         mov    ax,word ptr kbio[2]
  322.         mov    word ptr old_kbio[2],ax
  323.         mov    ax, offset intercept
  324.         mov    word ptr kbio,ax
  325.         mov    word ptr kbio[2],cs
  326.         sti
  327.  
  328.         mov    es,cs:[02ch]        ; release environment
  329.         mov    ah,49h
  330.         int    21h
  331.  
  332.         mov    dx,offset init_vectors    ; end of resident portion
  333.         int    27h            ; terminate but stay resident
  334. init_vectors    endp
  335.  
  336. cseg           ends
  337.  
  338.         END    begin
  339.  
  340.